// 这里没有解决跨域问题，但可以通过后解决跨域问题在后端的Controller层使用@CrossOrigin
import request from '../utils/request'

// 展示该进货单的货物
export function getReturnList(currentPage, pageSize) {
  return request({
    url: '/return',
    method: 'get',
    params: {
      currentPage,
      pageSize
    }
  })
}

// 增加进货单
export function addReturn(data,returnGoods) {
  return request({
    url: '/return',
    method: 'post',
    data: {
      factoryId: data.factoryId,
      price: data.price,
      status: data.status,
      time: data.time,
      returnGoods:JSON.stringify(returnGoods)
    }
  })
}

// 删除退货单
export function deleteReturn(ids) {
  return request({
    url: '/return/' + ids,
    method: 'delete',
  })
}


// 修改退货单
export function editReturn(data) {
  return request({
    url: '/return',
    method: 'put',
    data: {
      returnId: data.returnId,
      price: data.price,
      time: data.time,
      status: data.status,
      factoryId: data.factory.factoryId,
    }
  })
}
